package com.example.md.mddemo.repo;

import com.example.md.mddemo.entity.Person;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;

import java.util.List;

/**
 * Copyright © 2018年 ziniuxiaozhu. All rights reserved.
 *
 * @Author 临江仙 hzqiuxm@163.com
 * TODO:亲爱的临江仙，请写点注释吧...........
 * @Date 2018/8/1 19:56
 */
public interface PersonRepository extends MongoRepository<Person,ObjectId> {

    //根据名字查询地址
    @Query(value="{ 'name' : ?0 }", fields="{ 'name' : 1, 'address' : 1}")
    String findByName(String name);

    //根据des中exts字段的值查询
    @Query(value = "{'des.ext2' : ?0 }")
    List<Person> findByDesContains(String des);

}
